package com.ease.concurrent.thread.state;

/**
 * 3. 抢不到锁时处于什么状态？
 * 阻塞状态 BLOCKED
 *
 * @author: chenhs
 * @date: Created in 10:09 2019/12/27
 **/
public class ThreadStateDemo3_Synchronized {


    public static void main(String[] args) throws Throwable {

        Thread t1 = new Thread(() -> {
            synchronized (ThreadStateDemo3_Synchronized.class) {
                System.out.println(" t1抢到锁");
            }
        });

        /**主线程先拿到锁*/
        synchronized (ThreadStateDemo3_Synchronized.class) {
            //启动t1，t1这时拿不到锁->Blocked
            t1.start();
            Thread.sleep(1000L);
            System.out.println(" t1抢不到锁时的状态：" + t1.getState());
        }


    }

}
